<template>
  <div class="main">
    <div class="login_box">
      <div class="czy_logo"><img src="../assets/doctor/login_logo.png" /></div>
      <div class="login_table">
        <!-- <img src="../assets/doctor/yw_login_02.jpg" id="img1"/> -->
        <div style="position:absolute;top:6px;right:-70px;">
          <select id="glylb" name="glylb" v-model="duties">
            <option value="100" selected="selected">健康管理师</option>
            <option value="101">医技</option>
            <option value="102">市场</option>
            <option value="103">财务</option>
            <option value="104">客服</option>
          </select>
        </div>
        <table width="266" border="0" cellpadding="0" cellspacing="1">
          <tr>
            <td width="66"></td>
            <td colspan="4"><input type="text" v-model.trim="admincode" class="login_input01" /></td>
          </tr>
          <tr>
            <td colspan="5" height="12"></td>
          </tr>
          <tr>
            <td width="66"></td>
            <td colspan="4"><input type="password" v-model.trim="password" class="login_input02" /></td>
          </tr>
          <tr>
            <td colspan="5" height="12"></td>
          </tr>
          <tr>
            <td width="66"></td>
            <td><input type="text" class="login_input03" /></td>
            <td width="8"></td>
            <td align="left"><img src="../assets/doctor/yzm.jpg" width="65" height="29" /></td>
            <td width="48"><a href="#" class="loginlink">换一张</a></td>
          </tr>
          <tr>
            <td colspan="5" height="12"></td>
          </tr>
          <tr>
            <td width="66"></td>
            <td class="login_input04"><input type="submit" class="login_input04" value="" @click="doLogin" /></td>
            <td width="8"></td>
            <td align="left" colspan="2"><input type="reset" class="login_input05" value="" /></td>
          </tr>
        </table>
      </div>
      <div class="copyright">
        备案号：湘ICP备14004030号-2 长沙贝诺儿童健康产业公司<br />
        成长热线：0731-88900680 88900690 公司网址：http://www.beirocare.com，请速与我们联系
      </div>
    </div>
  </div>

</template>

<script>
import Vue from 'vue'
import VuejsDialog from 'vuejs-dialog'

Vue.use(VuejsDialog)

export default {
  name: 'Mechanism',
  data () {
    return {
      admincode: '',
      password: '',
      duties: '100'
    }
  },
  methods: {
    doLogin () {
      this.$http.get('login', {
        params: {
          admincode: this.admincode,
          password: this.password
        }
      }).then(resp => {
        this.resp = JSON.stringify(resp.data)
        console.log(resp.data)
        if (resp.data.code === 0) {
          if (resp.data.data.glylb === '健康医师') {
            if (this.duties === '100') {
              console.log(resp.data.data.glylb)
              this.$router.push({
                path: '/mechanismmain'
              })
            } else {
              alert('身份不匹配登录被拒绝')
            }
          }
          if (resp.data.data.glylb === '医技') {
            if (this.duties === '101') {
              console.log(resp.data.data.glylb)
              this.$router.push({
                path: '/market'
              })
            } else {
              alert('身份不匹配登录被拒绝')
            }
          }
          if (resp.data.data.glylb === '收银员') {
            if (this.duties === '103') {
              console.log(resp.data.data.glylb)
              this.$router.push({
                path: '/Financial'
              })
            } else {
              alert('身份不匹配登录被拒绝')
            }
          }
          if (resp.data.data.glylb === '线上客服') {
            if (this.duties === '104') {
              console.log(resp.data.data.glylb)
              this.$router.push({
                path: '/customer'
              })
            } else {
              alert('身份不匹配登录被拒绝')
            }
          }
        }
        if (resp.data.code === 5001) {
          confirm('用户名或密码错误登录被拒绝')
        }
      })
    }
  }
}
</script>

<style scoped="scoped">
  * {
    padding: 0;
    margin: 0;
  }

  body,
  html {
    background: #FBFCFF;
  }

  /* longin */
  .login_box {
    width: 1287px;
    top: -50px;
    left: 10px;
    height: 690px;
    position: relative;
    background-image: url(../assets/doctor/yw_login_02.jpg);
    background-repeat: no-repeat;
    background-position: left top;

  }

  .czy_logo {
    position: absolute;
    top: 50px;
    right: 536px;
  }

  .login_table {
    position: absolute;
    top: 290px;
    right: 510px;
    font-size: 12px;
    color: #000000;
  }

  .login_input01 {
    border: 1px solid #8bb0be;
    height: 30px;
    line-height: 30px;
    width: 174px;
    padding-left: 40px;
    /* background:#ebf5f8 url(../asserts/doctor/yw_user.jpg) no-repeat top left; */
    background: url(../assets/doctor/yw_user.jpg) no-repeat top left;
  }

  .login_input02 {
    border: 1px solid #8bb0be;
    height: 30px;
    width: 174px;
    padding-left: 40px;
    line-height: 33px;
    background: url(../assets/doctor/yw_info.jpg) no-repeat top left;
    margin-top: 8px;
  }

  .login_input03 {
    border: 1px solid #8bb0be;
    height: 30px;
    width: 78px;
    line-height: 33px;
    margin-left: 19px;

    /* background: url(../assets/doctor/login_bg03.jpg) no-repeat top left; */
    /* background:#ebf5f8 url(../assets/doctor/login_bg03.jpg) no-repeat top left; */

  }

  a.loginlink {
    color: #ff3101;
    text-decoration: none;
    margin-top: 50px;
    /* margin-top: 50px; */

  }

  a.loginlink:hover {
    color: #ff3101;
    text-decoration: underline;
  }

  .login_input04,
  .login_input05 {
    width: 100px;
    height: 35px;
    line-height: 35px;
    color: #ffffff;
    text-align: center;
    font-weight: bold;
    border: 0px;
    font-size: 14px;
    cursor: pointer;
  }

  .login_input04 {
    background-image: url(../assets/doctor/login_btn01.jpg);
    background-repeat: no-repeat;
    background-position: left top;
  }

  .login_input05 {
    background: url(../assets/doctor/login_btn02.jpg) no-repeat top left;
    margin-top: -8px;
  }

  .copyright {
    font-size: 12px;
    color: #335973;
    position: absolute;
    top: 620px;
    right: 320px;
    width: 616px;
    text-align: center;
  }

</style>
